﻿using Authority.Model;
using Common.Library;
using Tool.Model;

namespace AutoMapper.DTO
{
    /// <summary>
    /// 权限相关映射
    /// </summary>
    public class AuthorityProfile : Profile
    {
        public AuthorityProfile()
        {
            #region Button

            CreateMap<ButtonsOperateRequest, SysButtonEntity>();

            #endregion

            #region Menus

            CreateMap<MenusRootRequest, SysMenuEntity>();

            CreateMap<MenusChildRequest, SysMenuEntity>();

            CreateMap<MenusModifyRequest, SysMenuEntity>();

            CreateMap<SysMenuEntity, MenusListResponse>();

            #endregion

            #region Role

            CreateMap<RoleRootRequest, SysRoleEntity>();

            CreateMap<RoleChildRequest, SysRoleEntity>();

            CreateMap<RoleModifyRequest, SysRoleEntity>();

            CreateMap<SysMenuEntity, RoleMenusListResponse>();

            CreateMap<RoleMenuButtonModifyInfo, SysRoleButtonEntity>();

            CreateMap<SysRoleEntity, SelectListInfo>()
                .ForMember(p => p.value, opt => { opt.MapFrom(t => t.gCode); })
                .ForMember(p => p.name, opt => { opt.MapFrom(t => t.sName); });

            CreateMap<View_RoleMenuButtonEntity, RoleMenuButtonsListResponse>();

            #endregion

            #region Department

            CreateMap<SysDepartmentEntity, DepartmentsListResponse>();

            CreateMap<DepartmentRootRequest, SysDepartmentEntity>();

            CreateMap<DepartmentChildRequest, SysDepartmentEntity>();

            CreateMap<DepartmentModifyRequest, SysDepartmentEntity>();

            #endregion

            #region Post

            CreateMap<PostOperateRequest, SysPostEntity>();

            #endregion

            #region User

            CreateMap<SysPostEntity, SelectListInfo>()
                .ForMember(p => p.value, opt => { opt.MapFrom(t => t.gCode); })
                .ForMember(p => p.name, opt => { opt.MapFrom(t => t.sName); });

            CreateMap<UserAddRequest, SysUserEntity>();

            CreateMap<UserModifyRequest, SysUserEntity>();

            #endregion
        }
    }
}
